/*var net = require("net");
var url = require("url");

var server = net.createServer(function(socket){
	socket.on("end",function(){
		console.log("goodbye\n");
	});
	console.log('client connected');
	socket.write("hello\r\n");
	socket.pipe(socket); 
	// server.write("hello\r\n");
}).on("error", function(err){
	throw err;
});
	server.listen(54393,function(){
		var address = server.address();
			console.log("opened server on %j",address);
	});*/

var http = require("http");
var url = require("url");
var querystring = require("querystring");

/*var servHttp = http.createServer(function(req, res){
	res.writeHead(200, {"Content-Type":"text/plain;charset=utf-8;"});
	res.end("okey2");
});*/
// var postData = querystring.stringify({
//   'msg' : 'Hello World!'
// });
var options = {
  hostname: '192.168.1.34',
  port: 80,
  path: "/api.php?"+encodeURI('msg=Hello World'),
  method: 'get',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
    // 'Content-Length': Buffer.byteLength(postData)
  }
};
var req = http.request(options,function(res){
	console.log(`STATUS: ${res.statusCode}`);
	console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
	res.setEncoding('utf8');
	res.on("data",function(chunk){
		console.log(`BODY: ${chunk}`);
	});
	res.on("end",function(){
		console.log('No more data in response.');
	});
});
req.on('error', (e) => {
  console.log(`problem with request: ${e.message}`);
});
//req.write(postData);
req.end();

/*servHttp.listen(54393,null,function(){
		var address = servHttp.address();
			console.log("opened server on %j",address);
});*/